# https://docs.docker.com/engine/reference/builder/#arg
# @remark Please never modify it, the auto/release.sh will update it automatically.
ARG tag=v4.0.107
ARG url=https://gitee.com/ossrs/srs.git
ARG srt=https://gitee.com/mawenwu1983/srt
############################################################
# build
############################################################
ARG repo=registry.cn-hangzhou.aliyuncs.com/ossrs/srs:dev
FROM ${repo} AS build
ARG tag
ARG url
ARG srt
# Install required tools.
RUN yum install -y gcc make gcc-c++ patch unzip perl git tcl cmake openssl-devel
RUN cd /tmp && git clone ${srt}
RUN cd /tmp/srt && ./configure && make && make install
RUN cd /tmp && git clone --depth=1 --branch ${tag} ${url} srs
RUN cd /tmp/srs/trunk && ./configure --with-srt --use-sys-ssl && make && make install
# The default index.html and srs-console.
RUN cp /tmp/srs/trunk/research/api-server/static-dir/index.html /usr/local/srs/objs/nginx/html/
RUN cp /tmp/srs/trunk/research/api-server/static-dir/favicon.ico /usr/local/srs/objs/nginx/html/
RUN cp /tmp/srs/trunk/research/api-server/static-dir/crossdomain.xml /usr/local/srs/objs/nginx/html/
RUN cp -R /tmp/srs/trunk/research/console /usr/local/srs/objs/nginx/html/
RUN cp -R /tmp/srs/trunk/research/players /usr/local/srs/objs/nginx/html/
RUN cp -R /tmp/srs/trunk/3rdparty/signaling/www/demos /usr/local/srs/objs/nginx/html/

############################################################
# dist
############################################################
FROM centos:7.9.2009 AS dist
# RTMP/1935, API/1985, HTTP/8080, RTC/8000, SRT/10080
EXPOSE 1935 1985 8080 8000 10080
# FFMPEG 4.1
COPY --from=build /usr/local/bin/ffmpeg /usr/local/srs/objs/ffmpeg/bin/ffmpeg
# SRS binary, config files and srs-console.
COPY --from=build /usr/local/srs /usr/local/srs
# Default workdir and command.
WORKDIR /usr/local/srs
CMD ["./objs/srs", "-c", "conf/srt.conf"]
